package gamecomm.activity;

import android.app.Activity;
 
import android.content.Context;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class SettingsActivity extends Activity {
    Button btnsetLocation;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.settings);
        
     // Importing all assets like buttons, text fields
        btnsetLocation = (Button) findViewById(R.id.btnsetLocation);
 
        // Set Location Button Click event
        btnsetLocation.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
        TextView location = (TextView) findViewById(R.id.location);
        LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        Criteria crit = new Criteria();
        String providers = lm.getBestProvider(crit, false);
        Location loc = lm.getLastKnownLocation(providers);
        if (loc != null) {
            //latitude
            double t = loc.getLatitude();
            //longitude
            double t1 = loc.getLongitude();
            location.setText(t+","+t1);
        } else {
            location.setText("Couldn't get a GPS location");
        }
            }
        });
    }
}



